<?php
namespace app\admin\model;

use think\Config;
use think\Model;
use think\Db;
use think\Session;

class ExhibitionModel extends Model
{
	/**
	*	展会列表
	*/
	public function getExhibition($data)
	{
		$where = [];

		/* 展会内容 */
		$e_name = empty($data['e_name']) ? '' : $data['e_name'];
		$e_name = trim($e_name);
		if(!empty($e_name)){
			$where['e_name'] = $e_name;
		}

		/* 展会状态 */
		$e_status = empty($data['e_status']) ? '' : $data['e_status'];
		$e_status = trim($e_status);
		if(!empty($e_status)){
			$where['e_status'] = $e_status;
		}

		$result = Db::table('sz_exhibition')->where($where)->paginate(20,false,['query' => request()->param()]);

		return $result;

	}


	/**
	*	添加展会提交
	*/
	public function addExhibition($data)
	{
		if($data){
			$data['addtime'] = empty($data['addtime']) ? 0 : strtotime(trim($data['addtime']));

			$result = Db::table('sz_exhibition')->insert($data);

			return $result;

		}else{

			return false;
		}
	}

	/**
	*	获取单个展会信息
	*/
	public function getOne($id)
	{
		$result = Db::table('sz_exhibition')->where('id',$id)->find();

		return $result;
	}

	/**
	*	修改展会提交
	*/
	public function editExhibition($id,$data)
	{

		if($data){
			$data['addtime'] = empty($data['addtime']) ? 0 : strtotime(trim($data['addtime']));

			Db::table('sz_exhibition')->where('id',$id)->update($data);
			return 2;

		}else{

			return 3;
		}
	}
}